home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / cacheart.zip / CACHE.ART next >
Text File  |  1987-12-31  |  36KB  |  712 lines

  1. LIVING WITH DOS:  DISK CACHES       
  2. by Barry Simon
  3.  
  4. Copyright (c) 1987, Capital PC User Group Inc.
  5. This material may be republished only for internal use
  6. by other not-for-profit user groups.
  7.  
  8. Posted on Compuserve with permission of CPCUG.  May not be
  9. reproduced without including the above copyright notice.
  10.  
  11. Published in the March 1987 issue of the Capital PC Monitor; 
  12. discussion of extended memory has been changed from the published 
  13. article.
  14.  
  15.  
  16. I/O, I/O, Its Off to Work We Go!
  17.  
  18. There is much noise made about running 286 based machines at 8, 10 
  19. or even 12 Megahertz.  While running your computer's 
  20. microprocessor at a faster speed will make a difference, for many 
  21. tasks the difference is bounded because the limiting factor is 
  22. often the speed of your input and output devices known 
  23. collectively as I/O.  That these devices slow down the CPU is seen 
  24. by the typical times involved.  8 MHz means that the CPU goes 
  25. through 8 million cycles per second.  Since a single instruction 
  26. on the 80xx family of chips takes from two to over twenty cycles, 
  27. a CPU in the current generation of MS-DOS machine can run at 
  28. roughly 1 MIPS (millions of instructions per second). 
  29.  
  30. Memory chips are rated at speeds of 70-200 nanoseconds.  A
  31. nanosecond is a billionth of a second which means that such chips
  32. are capable of speed comparable to CPU speeds.  That the speeds
  33. are slightly less is shown by the need for "wait states", which
  34. slow down the CPU to allow access to memory at its speed; RAM
  35. speeds, however, are roughly equal to those of the CPU.  I/O
  36. speeds are considerably less.  Even a fast hard disk rated at 20
  37. milliseconds has a rated speed 100,000 times the speeds associated
  38. to RAM.  Of course, because the RAM speed is a statement about
  39. each access and hard disk access times involve the first access of
  40. a disk sector, the actual ratios are not that bad.
  41.  
  42. But memory access, even by slow memory chips, is much faster than
  43. even speedy hard disks; diskettes are even slower.  While disk
  44. transfer rates are slower than RAM exchanges, they are speedy
  45. compared to output through parallel or serial ports, where
  46. transfer rates are measured in 100's of bytes per second.  (1200
  47. baud, for example, means roughly 120 characters per second.)  And
  48. your console, the name for the combined keyboard/monitor I/O
  49. device must interface the computer's slowest component -- you;
  50. its speeds are often the slowest of all.
  51.  
  52. There are software tools to try to speed up I/O especially by
  53. using RAM for certain operations.  This month, I'll discuss one
  54. category of those tools -- disk caches; programs that can
  55. substantially speed up disk access.
  56.  
  57. In this article, I discuss six commercial and one shareware disk
  58. cache programs; the programs are:
  59.  
  60. o  Emmcache, a shareware product by Frank Lozier;
  61.  
  62. o  Lightning from the Personal Computer Support Group;
  63.  
  64. o  Polyboost from Polytron;
  65.  
  66. o  Quickcache from Microsystems Developers, Inc.;
  67.  
  68. o  Speedcache from FSS Ltd;
  69.  
  70. o  Super PC-Kwik from Multisoft Corp.; and
  71.  
  72. o  Vcache from Golden Bow Systems.
  73.  
  74.  
  75. What Is a Disk Cache?
  76.  
  77. Disk caches are based on the idea that you are likely to want to
  78. access a file that you accessed recently.  This is not only true
  79. for obvious data files like a database which you might search
  80. several times in a row, but also for program overlays and for the
  81. files that DOS often consults to locate other files: the FAT and
  82. the various directories, especially the root directory.
  83.  
  84. Thus every time that a file is accessed, a cache will keep a copy
  85. of that file in memory set aside especially for that purpose.
  86. Since this special memory is limited, the cache has to have an
  87. algorithm to decide which parts of the cache to clear out to make
  88. room for new sectors.  All the caches under discussion use the
  89. algorithm of discarding those parts of the cache which were least
  90. recently accessed; that is, not the ones that were first read the
  91. longest ago but rather than ones which were needed longest ago.
  92. Whenever DOS calls for a sector from disk, the cache program
  93. intercepts the call to check if the requested material is in the
  94. cache memory.  If it is, the copy in memory is used and a disk
  95. access is saved.  A cache can avoid anywhere from one-third to
  96. two-thirds of your disk accesses.  To allow a large cache, it is
  97. natural to put the data part of the cache (that is, the copies of
  98. the sectors which were read rather than code that controls this
  99. data) in extended or expanded memory.
  100.  
  101. For safety's sake, you would not want these programs to delay
  102. writing to disk material that DOS wants to write to disk; this is
  103. called keeping dirty buffers and none of these programs keep dirty
  104. buffers.  However, as I'll explain, DOS does some of its own disk
  105. caching and it does keep dirty buffers which can produce problems.
  106.  
  107. Do not confuse keeping dirty buffers, that is delaying writing to
  108. disk, with caching writes.  The latter means that the cache writes
  109. to disk but keeps a copy of the material which is written to disk
  110. if it is different from the copy that was read previously.  For
  111. example, if you load a file in your word processor, change it and
  112. save it, a program that caches writes will save a copy of the
  113. final file version in its cache while one that does not, will not
  114. keep such a copy.  All the commercial programs discussed in this
  115. article cache writes, but Emmcache does not.
  116.  
  117. When I first started using a cache, I found the experience eerie.
  118. I'd do some action that I often did and wondered why my disk
  119. access light wasn't going on.
  120.  
  121.  
  122. Types of Memory
  123.  
  124. In our discussion of caching, various references will be made to
  125. the different kinds of memory that are available to microcomputer
  126. users.  These include:
  127.  
  128. o  Conventional memory, the 640K of Random Access Memory (RAM)
  129. that is readily accessible by most 8088/8086/80186 computers.
  130.  
  131. o  Extended memory, the memory above 1 megabyte (up to 16
  132. megabytes) that is accessible by 80286 computers.  This memory
  133. is not normally accessible for use as conventional memory but is
  134. generally used for RAM disks, disk caches or print spoolers.  
  135.  
  136. o Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS) and 
  137. supporting memory boards (up to 8 megabytes) are paged in and out 
  138. of conventional memory, thereby providing the user with additional 
  139. memory for supported software. 
  140.  
  141.  
  142. Not a Memory Cache
  143.  
  144. You should be careful to distinguish between a disk cache and 
  145. memory caches.  There are circumstances where it may happen that 
  146. some of your RAM runs at a higher speed than most of your RAM.  In 
  147. that case, it may pay to cache some of the reading of instructions 
  148. from the slow RAM to speed up programs with loops. Two situations 
  149. are where you add a speedup (usually 80186- or 80286-based) board 
  150. to a PC with lots of old RAM typically at 200 nanoseconds or with 
  151. 386 machines where RAM that keeps up with the processor should be 
  152. rated at 100 or even 70 nanoseconds.  In any event, these 
  153. situations involve a memory cache, not a disk cache which is the 
  154. subject of this article. 
  155.  
  156.  
  157. Caches Versus RAM Disks
  158.  
  159. You can also cut down on access to a physical disk by using a RAM
  160. disk, that is by setting aside a part of RAM as a virtual disk
  161. which DOS accesses as if it were an ordinary disk.  There are
  162. several differences between RAM disks and disk caches.  Accessing
  163. files from a RAM disk is often slightly faster as our time tests
  164. will show.  Moreover, the first access of a file with a cache will
  165. be slower than later accesses.  On the negative side, you must
  166. decide in advance which files you'll want on the RAM disk; you'll
  167. also have to be sure to copy any changed data files from the RAM
  168. disk to a real disk or risk losing them when you power down or if
  169. your system crashes.
  170.  
  171. Which should you use?  That depends on how you use your computer.
  172. If you only use a few programs without extensive data files, a RAM
  173. disk is probably better if you can make one large enough to hold
  174. what it needs to.  In other circumstances, a cache may be
  175. preferable.  If you have the RAM, there may be sense in using
  176. both:  a RAM disk fo